<?php

namespace App\Http\Requests;

use App\Http\Requests\BaseRequest;

class StoreArticle extends BaseRequest
{
    /**
     * @var array 定义验证规则
     */
    private $rules = [
        // 这里代表创建表单需要验证的字段
        'create' => [
            'testCreate' => 'required'
        ],
        // 更新表单需要验证的字段
        'update' => [
            'testUpdate' => 'required'
        ],
        // 不管是创建还是更新都要验证的字段
        'common'   => [
            'type_id'=>'required|integer',
            'content'=>'required|string',
            'title'=>'required|string',
            'tag_ids'=>'required|string',
            'config.*.title' => 'required|string',
            'config.*.details' => 'present',
            'config.*.set_key' => 'required|string',
            'config.*.set_value' => 'present',
            'token'  => 'required|string',
        ],
    ];
    private $message=[

    ];
    public function rules()
    {

        if(self::isMethod('post')){
//            if(static::getPathInfo()=="/admin/article/store"){ //添加
//
//            }else{
//
//            }
        }

        $this->useRules=[
            'type_id'=>'required|integer',
            'content'=>'required|string',
            'title'=>'required|string',
            'tag_ids'=>'required|string',
        ];
        return  $this->useRules;
    }
    /**
     * 定义字段名中文
     *
     * @return array
     */
    public function attributes()
    {

        $this->useAttributes=[
            'type_id.required'=>'分类',
            'content.required'=>'内容',
            'title.required'=>'标题',
            'tag_ids'=>'标签id',
        ];

        return  $this->useAttributes;
    }

}
